﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using MongoServices.Tests.TestHelpers;

namespace MongoServices.Tests.MongoServicesModelTests
{
	public class MongoServicesModelTests : TestBase
	{
		public MongoServicesModelTests()
		{
			Setup();
		}

		private void Setup()
		{
		}
	}

	public class WhenMarkForDeleteIsCalled : MongoServicesModelTests
	{
		[Fact]
		public void MarkedForDeleteIsTrue()
		{
			var testModel = new TestModelSimple();

			testModel.UnmarkForDelete();
			testModel.MarkForDelete();

			Assert.True(testModel.MarkedForDelete);
		}
	}

	public class WhenUnmarkForDeleteIsCalled : MongoServicesModelTests
	{
		[Fact]
		public void MarkedForDeleteIsFalse()
		{
			var testModel = new TestModelSimple();

			testModel.MarkForDelete();
			testModel.UnmarkForDelete();

			Assert.False(testModel.MarkedForDelete);
		}
	}

	public class WhenTheModelIsSaved : MongoServicesModelTests
	{
		[Fact]
		public void TheMarkedForDeletePropertyIsNotSavedToDatabase()
		{
			var testModel = new TestModelSimple();

			testModel.MarkForDelete();

			CollectionTestModelSimple.Save(testModel);

			var results = CollectionTestModelSimple.FindAllAs<TestModelSimple>();

			Assert.False(results.First().MarkedForDelete);
		}
	}
}
